let app = getApp();
const { showToast } = require("/utils/common");
const { moment } = require("/utils/core");
import { validListItem } from "/utils/commonMethod";
import omsRequest from "/utils/omsRequest";
import { getDistributableList } from "/api/distributeAchievement";
Page({
  data: {
    userInfo: null,
    saleMonthTargetTab: [],
    currentDate: moment().format("YYYY.MM"),
    currentTabIndex: 0,// 默认新签商户数
    collectionListTitle: ['序号', '城市', '目标'],
    list: []
  },
  onLoad(option) {
    this.getDistributableList();
    this.setData({
      currentTabIndex: option && option.currentTabIndex,
      saleMonthTargetTab: option && JSON.parse(option.saleMonthTargetTab),
      userInfo: app.globalData.userInfo
    })
  },
  cusTitleChange(e) {
    this.setData({
      list: [],
      currentTabIndex: e.currentTarget.dataset.index
    })
    this.getDistributableList()
  },
  getDistributableList() {
    dd.showLoading({
      content: '加载中...'
    })
    omsRequest({
      url: getDistributableList
    }).then((res) => {
      if (res.success) {
        this.setData({
          list: res.voList
        })
        dd.hideLoading()
      }
    })
  },
  onChangeVo(vo) {
    console.log(vo,"vp")
    this.data.saleMonthTargetTab[this.data.currentTabIndex].distributableFlag = vo.distributableFlag
    this.setData({
     saleMonthTargetTab: this.data.saleMonthTargetTab
    })
  }
});
